<?php
/**
 * @name: 公共服务处理类
 * @author: wudean
 * @Date: 20180531
 */
namespace App\Services;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;

class SystemService
{

    /**
     * @param $file
     * @return string
     * @name 获取视频播放时长
     * @user IHammer
     */
    public static function getVideoTime($file){
        //当前域名
        $url = $_SERVER['SERVER_NAME'];

        if($url=="wapi.ihammer.cn"){ //测试服务器
            $ffmpeg = "/usr/bin/bin/ffmpeg";
        }else{//本地环境
            $ffmpeg = "ffmpeg";
        }
        return exec($ffmpeg." -i ".$file." 2>&1 | grep 'Duration' | cut -d ' ' -f 4 | sed s/,//");

    }

    public static function  generated(){

    }

    /**
     * @param $seconds
     * @return string
     * @name 转秒
     * @user IHammer
     */
    static function changeTimeType($seconds){
        if ($seconds >3600){
            $hours =intval($seconds/3600);
            $minutes = $seconds % 3600;
            $time = $hours.":".gmstrftime('%M:%S',$minutes);
        }else{
            $time = gmstrftime('%H:%M:%S',$seconds);
        }
        return$time;
    }
}
